package org.zhhw.ribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: jack
 * \* Date: 2019/1/22
 * \* Time: 17:15
 * \* Description:
 * \
 */
@Service
public class HelloService {
    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "fallBackInfo")
    public String getHelloInfo(){
        return restTemplate.getForObject("http://eureka-client/",String.class);
    }

    private String fallBackInfo(){
        return "hello service is not available ";
    }
}
